package com.ssy.lingxi.order.controller.platform;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.vo.basic.request.OrderPayChannelVO;
import com.ssy.lingxi.order.model.vo.payment.request.PaymentParameterChannelVO;
import com.ssy.lingxi.order.model.vo.payment.request.PaymentParameterInsertOrUpdateVO;
import com.ssy.lingxi.order.model.vo.payment.response.PaymentParameterDetailVO;
import com.ssy.lingxi.order.model.vo.payment.response.PaymentParameterItemVO;
import com.ssy.lingxi.order.model.vo.payment.response.PaymentParameterPayTypeDetailVO;
import com.ssy.lingxi.order.model.vo.platform.request.MemberPaymentIdVO;
import com.ssy.lingxi.order.model.vo.platform.request.MemberPaymentPageVO;
import com.ssy.lingxi.order.model.vo.platform.request.MemberPaymentStatusVO;
import com.ssy.lingxi.order.model.vo.platform.request.MemberPaymentVO;
import com.ssy.lingxi.order.model.vo.platform.response.MemberPaymentQueryVO;
import com.ssy.lingxi.order.service.platform.IPlatformPaymentParameterService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 平台后台 - 平台支付参数设置
 * @author 万宁
 * @version 2.0.0
 * @date 2021-08-12
 */
@RestController
@RequestMapping("/order/platform/payment")
public class PlatformPaymentParameterController {
    @Resource
    private IPlatformPaymentParameterService platformPaymentParameterService;

    /**
     * 查询支付参数配置详情
     * @param headers HttpHeaders信息
     * @return 查询结果
     */
    @RequestMapping(value = "/parameter/find", method = RequestMethod.GET)
    public Wrapper<List<PaymentParameterPayTypeDetailVO>> findParameters(@RequestHeader HttpHeaders headers) {
        return platformPaymentParameterService.findParameters(headers);
    }

    /**
     * 根据支付渠道，查询支付参数下拉框列表
     * @param headers HttpHeaders信息
     * @param channelVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/parameter/channel/find", method = RequestMethod.GET)
    public Wrapper<List<PaymentParameterItemVO>> findPayChannelParameters(@RequestHeader HttpHeaders headers, @Valid OrderPayChannelVO channelVO) {
        return platformPaymentParameterService.findPayChannelParameters(headers, channelVO);
    }

    /**
     * 新增或修改平台支付参数设置
     * @param headers HttpHeaders信息
     * @param parameterVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/parameter/create", method = RequestMethod.POST)
    public Wrapper<Void> createParameters(@RequestHeader HttpHeaders headers, @RequestBody @Valid PaymentParameterInsertOrUpdateVO parameterVO) {
        return platformPaymentParameterService.createParameters(headers, parameterVO);
    }

    /**
     * “商户参数配置” - 查询会员通用支付参数配置列表
     * @param headers HttpHeaders信息
     * @param channelVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/member/common/parameter/list", method = RequestMethod.GET)
    public Wrapper<List<PaymentParameterDetailVO>> findMemberCommonParameters(@RequestHeader HttpHeaders headers, @Valid OrderPayChannelVO channelVO) {
        return platformPaymentParameterService.findMemberCommonParameters(headers, channelVO);
    }

    /**
     * “商户参数配置” - 根据支付渠道，查询会员通用支付参数下拉框列表
     * @param headers HttpHeaders信息
     * @param channelVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/member/common/parameter/find", method = RequestMethod.GET)
    public Wrapper<List<PaymentParameterItemVO>> findMemberCommonPayChannelParameters(@RequestHeader HttpHeaders headers, @Valid OrderPayChannelVO channelVO) {
        return platformPaymentParameterService.findMemberCommonPayChannelParameters(headers, channelVO);
    }

    /**
     * “商户参数配置” - 新增或修改会员通用参数设置
     * @param headers HttpHeaders信息
     * @param parameterVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/member/common/parameter/create", method = RequestMethod.POST)
    public Wrapper<Void> createMemberCommonParameters(@RequestHeader HttpHeaders headers, @RequestBody @Valid PaymentParameterChannelVO parameterVO) {
        return platformPaymentParameterService.createMemberCommonParameters(headers, parameterVO);
    }

    /**
     * 分页查询商户支付参数配置列表
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/member/parameter/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberPaymentQueryVO>> pageMemberPayments(@RequestHeader HttpHeaders headers, @Valid MemberPaymentPageVO pageVO) {
        return platformPaymentParameterService.pageMemberPayments(headers, pageVO);
    }

    /**
     * 新增商户支付参数配置时，查询支付参数下拉框列表
     * @param headers HttpHeaders信息
     * @return 查询结果
     */
    @RequestMapping(value = "/member/parameter/find", method = RequestMethod.GET)
    public Wrapper<List<PaymentParameterItemVO>> findMemberPaymentParameters(@RequestHeader HttpHeaders headers) {
        return platformPaymentParameterService.findMemberPaymentParameters(headers);
    }

    /**
     * 新增或修改商户支付参数配置
     * @param headers HttpHeaders信息
     * @param paymentVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/member/parameter/create", method = RequestMethod.POST)
    public Wrapper<Void> createMemberPayment(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberPaymentVO paymentVO) {
        return platformPaymentParameterService.createMemberPayment(headers, paymentVO);
    }

    /**
     * 修改商户支付参数配置状态
     * @param headers HttpHeaders信息
     * @param statusVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/member/parameter/status", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberPaymentStatus(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberPaymentStatusVO statusVO) {
        return platformPaymentParameterService.updateMemberPaymentStatus(headers, statusVO);
    }

    /**
     * 删除商户支付参数配置
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 删除结果
     */
    @RequestMapping(value = "/member/parameter/delete", method = RequestMethod.POST)
    public Wrapper<Void> deleteMemberPayment(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberPaymentIdVO idVO) {
        return platformPaymentParameterService.deleteMemberPayment(headers, idVO);
    }
}
